#!/usr/bin/python2.5
# Copyright (c) 2008 MalFind

__author__ = "mavrommatis@gmail.com (Panayiotis Mavrommatis)"

from google.appengine.ext import db

class Digest(db.Model):
  '''An entry in the SB list'''
  hash = db.StringProperty(required=True)


class Query(db.Expando):
  '''A user query and its (consise) findings.'''
  url = db.StringProperty(required=True)
  when = db.DateTimeProperty(auto_now_add=True)
  matches_blacklist = db.BooleanProperty(required=True)
  contains_blacklist = db.BooleanProperty(required=True)


class Finding(db.Expando):
  sort = db.StringProperty(required=True)  # eg. "/tag/iframe"
  data = db.TextProperty()  # eg "<iframe src=blah.html>"
  url = db.LinkProperty()  # eg blah.html
  url_blacklisted = db.BooleanProperty()


class Assessment(db.Expando):
  '''An Assessment contains all the results of our actions, i.e. 
  fetching a URL, parsing it, comparing against the blacklist. '''
  url = db.LinkProperty()
  when = db.DateTimeProperty(auto_now_add=True)
  top_blacklisted = db.BooleanProperty()
  response_body = db.BlobProperty()
  # errors = db.StringListProperty()
  findings = [db.ReferenceProperty()]
  

